// 获取文章首页数据
const db = require("../lib/db")

function main(){
    return new Promise((resolve,reject)=>{
        let sql = "select * from main"
        db.querySql(sql).then(data=>{
            if(data.length == 0){
                resolve(404)
            }else{
                let arr =[]
                data.map(element=>{
                    arr.push({
                    id : Buffer.from(String(element.id)).toString("base64"),
                    title :element.title,
                    descs : element.descs,
                    author : element.author,
                    authorId : element.authorId,
                    classify : element.classify,
                    content : element.content
                    })
                })
                resolve(arr)
                console.log(arr)
            }
        })
    })
}

module.exports = main